﻿#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using OpenComposite.Base;
using OpenComposite.EII.Repository;
using OpenComposite.EII.Designer.Org.Forms;

#endregion

namespace OpenComposite.SOBADesigner
{
	internal partial class FormOrgDesigner : WeifenLuo.WinFormsUI.Docking.DockContent
	{
		#region Constructors

		public FormOrgDesigner(IServiceProvider serviceProvider, Organization org)
		{
			InitializeComponent();

			m_orgCtrl = new OpenComposite.EII.RepositoryUIs.UCOrganisationDesigner(serviceProvider);
			m_orgCtrl.Dock = DockStyle.Fill;
			m_orgCtrl.RepositoryItem = org;
			this.Controls.Add(m_orgCtrl);
		}

		#endregion Constructors

		#region Interface

		#region Properties

		/// <summary>
		/// Get and set the UserID property.
		/// </summary>
		/// <value></value>
		internal string UserID
		{
			get { return m_userID; }
		}

		/// <summary>
		/// Get and set the UserPassword property.
		/// </summary>
		/// <value></value>
		internal string UserPwd
		{
			get { return m_userPwd; }
		}

		/// <summary>
		/// Get and set the UserOrg property.
		/// </summary>
		/// <value></value>
		internal string UserOrg
		{
			get { return m_userOrg; }
		}

		#endregion Properties

		#region Methods

		internal void ShowFrmNewOrg()
		{
			m_userID = "";
			m_userPwd = "";
			m_userOrg = "";

			FormNewOrganization frm = new FormNewOrganization();
			if ( frm.ShowDialog() == DialogResult.OK ) {
				m_userID = frm.AdminUserId;
				m_userPwd = frm.AdminPassword;
				m_userOrg = frm.AdminOrgname;
			}

			frm.Close();
			this.Close();
		}

		#endregion Methods

		#endregion Interface

		#region Members

		#region Private Vars

		private OpenComposite.EII.RepositoryUIs.UCOrganisationDesigner m_orgCtrl;

		private string m_userID = "";
		private string m_userPwd = "";
		private string m_userOrg = "";

		#endregion Private Vars

		#region Private Methods

		#endregion Private Methods

		#region Eventhandlers

		private void FormOrgDesigner_FormClosing(object sender, FormClosingEventArgs e)
		{
			m_orgCtrl.RepositoryItem.Save();
			#region old
			//DialogResult result = MessageBox.Show("Do you want to save the changes?", this.TabText,
			//                                      MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
			//if ( result == DialogResult.No ) {
			//    e.Cancel = false;
			//} else if ( result == DialogResult.Cancel ) {
			//    e.Cancel = true;
			//} else {
			//    e.Cancel = false;
			//}
			#endregion
		}

		#endregion Eventhandlers

		#endregion Members

	}
}